package com.zhilun;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class FastJsonExample {

    public static void main(String[] args) {
        String jsonString = "{\n" +
                "    \"formatDate\":\"2024-09-10 11:12:28\",\n" +
                "    \"data\":{\n" +
                "        \"gpdModel\":\"北斗+GPS\",\n" +
                "        \"bandStatus\":1,\n" +
                "        \"lowPower\":false,\n" +
                "        \"carrierNo\":\"皖MT530挂\",\n" +
                "        \"carrierWheelVOS\":[\n" +
                "            {\n" +
                "                \"bindFlag\":1,\n" +
                "                \"sensorVOS\":[\n" +
                "                    {\n" +
                "                        \"alarmFlagList\":[],\n" +
                "                        \"alarmFlag\":0,\n" +
                "                        \"sensorType\":\"01\",\n" +
                "                        \"id\":305348,\n" +
                "                        \"sensorNo\":\"67000206\",\n" +
                "                        \"wheelId\":100710\n" +
                "                    }\n" +
                "                ],\n" +
                "                \"carrierNo\":\"皖MT530挂\",\n" +
                "                \"id\":100710,\n" +
                "                \"position\":\"L0102\",\n" +
                "                \"alarmFlag\":0\n" +
                "            },\n" +
                "            {\n" +
                "                \"bindFlag\":0,\n" +
                "                \"sensorVOS\":[\n" +
                "                    {\n" +
                "                        \"alarmFlagList\":[],\n" +
                "                        \"alarmFlag\":0\n" +
                "                    }\n" +
                "                ],\n" +
                "                \"carrierNo\":\"皖MT530挂\",\n" +
                "                \"id\":100709,\n" +
                "                \"position\":\"L0101\",\n" +
                "                \"alarmFlag\":0\n" +
                "            }\n" +
                "        ],\n" +
                "        \"wheelPosition\":\"2,2,2\",\n" +
                "        \"alarm\":false,\n" +
                "        \"id\":89226\n" +
                "    },\n" +
                "    \"success\":true,\n" +
                "    \"message\":\"ok\",\n" +
                "    \"status\":200\n" +
                "}";

        // 使用 FastJSON 解析 JSON 字符串
        ZhiLunResponse<ZhiLunCarrierInfoDetailResult> response = JSON.parseObject(
                jsonString, 
                new com.alibaba.fastjson.TypeReference<ZhiLunResponse<ZhiLunCarrierInfoDetailResult>>() {}
        );

        // 打印解析结果
        System.out.println("Success: " + response.isSuccess());
        System.out.println("Message: " + response.getMessage());
        System.out.println("Carrier No: " + response.getData().getCarrierNo());
        System.out.println("Wheel Position: " + response.getData().getWheelPosition());
    }
}
